package com.bruce.codeFactory.genericity;

/**
 * @author luotuan
 * @Description
 * @create 2019-05-06 20:16
 **/
public class Holder<T> {
    private T value;
    public Holder(){};
    public Holder(T val){
        this.value = val;
    }
    public void set(T val){
        this.value = val;
    }
    public T get(){
        return value;
    }
    public boolean equals(Object obj){
        return value.equals(obj);
    }

    public static void main(String[] args) {
        Holder<Apple> appleHolder = new Holder<>(new Apple());
        Apple d = appleHolder.get();
        appleHolder.set(d);
        Holder<? super Apple> fruitHolder = appleHolder;
        fruitHolder.set(new Apple());
    }
}
class Fruit{};
class Apple extends Fruit{};
class Orange extends Fruit{};

